<?php

echo "\n======================\nRunning tests.php ... \n======================\n\n";
		

include "System/FS/PathTool.php";

/*
			$rootPath = 'D:/php_dev/workspace/kohv/';							
			$pt = new System_FS_PathTool($rootPath);						
			$globalPath = 'D:/php_dev/workspace/kohv/Core/Ensum';
						
			$localPath = $pt->globalToLocal($globalPath);			
			if ($localPath===false) exit("the path is bad");			
			echo  "\n\nlp: " . $localPath;
*/		
			

/*
			$rootPath = 'D:/php_dev/workspace/kohv/';							
			$pt = new System_FS_PathTool($rootPath);						
			$localPath = '/Core/../../../';
			$localPath = '..';			
			$realPath = $pt->localToGlobal($localPath);			
			if ($realPath===false) exit("the path is bad");			
			echo  'rp: ' . $realPath;		
*/

			
/*
			echo php_uname();
			exit();
*/

/*
// validating a path
			//page 396		
			
			$path = '/core/test/////dd//://';
			
			// replace multiple slashes with the single ones 
			$path = preg_replace('%/{2,}%', '/', $path);
			
			echo "\n\npath: $path\n\n";
			
			// valid kohv path pattern
			$pattern = '%^(\/?[^\\<>|"*?:\r\n\s]+\/?)+$%';
						
			$res = preg_match($pattern, $path);

			echo "\n\nres=$res\n\n";
			
			//if ((bool)$res) return $path;			
			//return false;
			
			
			//to make a valid path:
			//	1. search for multiple slashes and replace them with single slashes
			//	2. apply validation pattern 
*/





/*
// compound arg test

			$argsString = 'show "use well " horse'; 
			///////////////////////////			

			$args = array();
			$curArg = "";
			$char = "";
			
			// flag to indicate if an argument is compound, i.e. has spaces and is surrounded with the quotes.
			$compoundArgFlag = false;
			
			$argStrLen = strlen($argsString);
			for($i=0; $i<$argStrLen; $i++)
			{
				$char = $argsString[$i]; 

				if ($char !== ' ' && $char !== '"')
				{
					$curArg .= $argsString[$i];
					continue;
				}
				
				if ($char === '"')
				{
					$compoundArgFlag = !$compoundArgFlag;
					continue;
				}
				
				if ($char === ' ' && $compoundArgFlag === false)
				{
					array_push($args, trim($curArg));
					$curArg = "";
					continue;
				}
					
				if($char === ' ' && $compoundArgFlag === true)
				{
					$curArg .= ' ';
					continue;
				}
				
				echo "\nNevedomaya Xuinya!!!\n";
				
			}
			
			if ( strlen($curArg) > 0 )
			{
					array_push($args, trim($curArg));
					$curArg = "";
			}
			
			
			print_r($args);
*/